package com.example.demo.blockqueue;

/**
 * @desc: <br/>
 * @author: Jingbo Hu<br/>
 * @time：2021年01⽉21⽇<br/>
 * @version：v1.0.0<br>
 */
public class JoinDemo {

    /**
     * 可以保证线程执行顺序
     */
    private static Thread[] threads = new Thread[10];

    public static void main(String[] args) {
        for (int i = 0; i < 10; i++) {
            threads[i] = new Thread(new Runnable() {
                @Override
                public void run() {
                    System.out.println("线程-【" + Thread.currentThread().getName() + "】正在执行任务.....");
                }
            });

            try {
                threads[i].start();
                threads[i].join();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("所有线程执行完毕.......");
    }
}
